package com.shuoyue.ycgk.ui.mok;

import android.graphics.Color;

import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseViewHolder;
import com.shuoyue.ycgk.R;
import com.shuoyue.ycgk.base.baseadapter.AppBaseQuickAdapter;
import com.shuoyue.ycgk.entity.SortInfo;
import com.shuoyue.ycgk.entity.Sourt;
import com.shuoyue.ycgk.utils.GlideUtil;

import java.util.List;

public class SortAdapter extends AppBaseQuickAdapter<Sourt> {
    public SortAdapter(@Nullable List<Sourt> data) {
        super(R.layout.item_sort, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, Sourt sortInfo) {
        helper.setText(R.id.name, sortInfo.getUsername());

        helper.setText(R.id.score, sortInfo.getScore() + "");
        helper.setText(R.id.text_sort, sortInfo.getRank() + "");
        GlideUtil.loadImageCircular(mContext, sortInfo.getAvatar(), R.mipmap.index_head, helper.getView(R.id.head));
        helper.setTextColor(R.id.score, Color.parseColor(sortInfo.getRank() > 3 ? "#000000" : "#E82E23"));
        if (sortInfo.getRank() == 1) {
            helper.setGone(R.id.img_sort, true);
            helper.setGone(R.id.text_sort, false);
            helper.setImageResource(R.id.img_sort, R.mipmap.sort_1);
        } else if (sortInfo.getRank() == 2) {
            helper.setGone(R.id.img_sort, true);
            helper.setGone(R.id.text_sort, false);
            helper.setImageResource(R.id.img_sort, R.mipmap.sort_2);

        } else if (sortInfo.getRank() == 3) {
            helper.setGone(R.id.img_sort, true);
            helper.setGone(R.id.text_sort, false);
            helper.setImageResource(R.id.img_sort, R.mipmap.sort_3);

        } else {
            helper.setGone(R.id.img_sort, false);
            helper.setGone(R.id.text_sort, true);
        }
    }
}
